#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

int main()
{
    int fd = open("./hello",O_RDWR|O_CREAT,0664);
    if(fd<0){
        perror("open");
        return -1;
    }

    write(1,"before dup2\0",12);
    printf("dump2\n");
    dup2(fd,1);

    write(1,"hahaha",6);
    return 0;
}